package com.yjq.blog.user.constant;

import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;

public class CodeConstant {

    public static Integer CODE_MIN = 100000;
    public static Integer CODE_MAX = 999999;

    private static String getPhoneCodeKey = "login:getCode:phone:";

    public static String getCodeKey(String phone, String type) {
        return getPhoneCodeKey.concat("code:").concat(type).concat(":").concat(phone);
    }

    public static String getIpTotalTimesKey(String ip) {
        return getPhoneCodeKey.concat("ipTimes:").concat(DateFormatUtils.format(new Date(), "yyyy-MM-dd:")).concat(ip);
    }

    public static String getPhoneTotalTimesKey(String phone) {
        return getPhoneCodeKey.concat("phoneTimes:").concat(phone);
    }

}
